from fastapi import APIRouter, Request
from app.parameter import LoginParam,RegisterParam,UpdateUserInfoParam
from app.service import UserService
router = APIRouter(tags=["用户路由"])
from utils import DEBUG

@router.post("/login")
async def index(loginParam: LoginParam):
    DEBUG(loginParam)
    return UserService.login(loginParam)

@router.post("/register")
async def register(registerParam: RegisterParam):
    DEBUG(registerParam)
    return UserService.register(registerParam)

@router.post("/user/update")
async def updateUser(updateParam: UpdateUserInfoParam, request: Request):
    DEBUG(updateParam)
    updateParam.userId = request.scope['token_data']["id"]
    return UserService.updateUserInfo(updateParam)